<?php
if ($do === 'addEvent') {
	$day = $_POST['day'];
	$eventtype = $_POST['eventtype'];
	$starttime = date('H:i:s',strtotime($_POST['starttime']));

	// The following if statement is pointless, other than I can't figure out ANY other way to send a null value to the mysql field endtime.  It should just be a matter of setting $endtime to NULL or unsetting it, but apparently that's not good enough for the damned programmers!
	if ((isset($_POST['endtime'])) && (($_POST['endtime'] != "") || ($_POST['endtime']) != 0)) {
		$endtime = date('H:i:s', strtotime($_POST['endtime']));
			mysql_query("INSERT INTO `schedule` SET `day`='".mysql_real_escape_string($day)."', `eventtype`='".mysql_real_escape_string($eventtype)."', `starttime`='".mysql_real_escape_string($starttime)."', `endtime`='".mysql_real_escape_string($endtime)."' ");
		echo('the condition is true');
	} else {
			mysql_query("INSERT INTO `schedule` SET `day`='".mysql_real_escape_string($day)."', `eventtype`='".mysql_real_escape_string($eventtype)."', `starttime`='".mysql_real_escape_string($starttime)."' ");
	}

	echo('event added');
echo("day= $day, eventtype = $eventtype, starttime = " . $starttime . ", endtime = $endtime");
} elseif ($do === 'deleteEvent') {
	mysql_query("DELETE FROM `schedule` WHERE `id`='".mysql_real_escape_string($_GET['id'])."' ");
	echo('event deleted from schedule <br />');
}
?>

<?php
include("./mode/schedule.inc");
?>